<?php include "../public/header.php";?>
<?php include "../public/header_show.php";?>
<body id="xiangqingPage">
<div id="xiangqingBox">
    <div class="page-title">
        <div class="page-title-con">
            <span class="pageshowtitle">详情</span>
            <div class="page-title-opt-list">
                <?php include "../public_flow/flow_show_optbut.php";?>
                <button class="layui-btn layui-btn-sm btn-light marginr5 opt">
                    操作<i class="layui-icon layui-icon-down layui-font-12"></i>
                </button>
                <span id="page-close" class="page-close" onclick="layer_close()">×</span>
            </div>
        </div>
    </div>
    <div class="main-container">

        <div><?php include "../public_flow/flow_show_info.php";?></div>

        <div class="table-box tablenes">
            <div class="title"><span>基本信息</span><span onclick="go_to_engin_xiang()" class="colorlan" style="float: right;margin-right: 12px">查看工程概况</span></div>
            <table class="layui-table">
                <tbody>
                <tr><td class="tt">工程名称</td><td class="tv colorlan" id="enginname" colspan="3"></td></tr>
                </tbody>
            </table>
        </div>


        <div class="table-box tablenes">
            <div class="title">销售方（乙方）信息</div>
            <table class="layui-table">
                <tbody>
                <tr><td class="tt">销售方(乙方)</td><td id="gonger" class="tv"></td><td class="tt">联系电话</td><td id="gongtel" class="tv"></td></tr>
                </tbody>
            </table>
        </div>


        <div class="table-box tablenes">
            <div class="title">本次采购合同信息</div>
            <table class="layui-table">
                <tbody>
                <tr><td class="tt">合同名称</td><td id="name" class="tv"></td><td class="tt">合同编号</td><td id="number" class="tv"></td></tr>
                <tr><td class="tt">采购类型</td><td id="caitype_name" class="tv"></td><td class="tt">合同类型</td><td id="hetype_name" class="tv"></td></tr>
                <tr><td class="tt">合同金额(元)</td><td id="money" class="tv"></td><td class="tt">合同结算金额(元)</td><td id="jiemoney" class="tv"></td></tr>
                <tr><td class="tt">发票类型</td><td id="qianpiaotype_name" class="tv"></td><td class="tt">税率(%)</td><td id="rate" class="tv"></td></tr>
                <tr><td class="tt">购买方(甲方)</td><td id="caier_name" class="tv"></td><td class="tt">合同状态</td><td id="state_name" class="tv"></td></tr>
                <tr><td class="tt">签订日期</td><td id="qiandt" class="tv" colspan="3"></td></tr>
                <tr><td class="tt">备注</td><td class="tv" id="explain" colspan="3"></td></tr>
                </tbody>
            </table>
        </div>

        <div><?php include "../public/upinfo_show.php";?></div>

        <div><?php include "../public_flow/flow_show_flowrelas.php";?></div>

        <div class="table-box tablenes">
            <script type="text/html" id="toolbarDemo">合同变更</script>
            <div class="tableShow">
                <table id="datalist" lay-filter="datalist"></table>
            </div>
        </div>

        <div class="table-box tablenes">
            <script type="text/html" id="toolbarDemo_ming">
                <span>合同明细</span>
            </script>
            <div class="tableShow">
                <table id="datalist_ming" lay-filter="datalist_ming"></table>
            </div>
        </div>

        <div><?php include '../public_flow/flow_show_shenlog.php'?></div>
        <div><?php include '../public_flow/flow_show_talk.php'?></div>
        <div><?php include '../public/opt_browse.php'?></div>
    </div>
</div>
<script>
    var param_id = getQueryVariable('id') || 0;
    var pub_enginid;
    layui.use(['form', 'layer', "laytp",'element','dropdown','laypage','table','soulTable'], function() {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable,element = layui.element;

        facade.ajax({url: ask_contract_cai_show, data:{id: param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;
                var engininfo = res.data.engininfo;

                if(engininfo){
                    pub_enginid = engininfo.id
                    $("#enginname").text(engininfo.name).click(function () {
                        openPage('../engin/show.php?id='+engininfo.id);
                    });
                }






                $("#state_name").html(data.state_name);
                $("#name").text(data.name);
                $("#number").text(data.number);
                $("#caitype_name").text(data.caitype_name);
                $("#hetype_name").text(data.hetype_name);
                $("#qianpiaotype_name").text(data.qianpiaotype_name);
                $("#caier_name").text(data.caier_name);
                $("#gonger").text(data.gonger);
                $("#myer").text(data.myer);
                $("#gongtel").text(data.gongtel);
                $("#qiandt").text(data.qiandt);
                $("#money").text(parseFormatNum(data.money));
                $("#jiemoney").text(parseFormatNum(data.jiemoney));
                $("#rate").text(data.rate);
                $("#explain").text(data.explain);

                var mytableList = table.render({
                    elem: "#datalist",data:res.data.bian, toolbar: '#toolbarDemo', page: false
                    ,limit:TabInitShow.limit,soulSort: TabInitShow.soulSort,method: TabInitShow.method, overflow: TabInitShow.overflow
                    ,defaultToolbar: TabInitShow.defaultToolbar,filter: TabInitShow.filter ,text: TabInitShow.text
                    ,request: TabInitShow.request,response: TabInitShow.response,contextmenu:get_table_contextmenu(soulTable)
                    , cols: [[
                        {type:'numbers',title:'序号'}
                        ,{field:'',title:'流程状态',templet: function(d){
                                if(d.billid > 0){
                                    if(d.status == 0){
                                        return '<span class="list_billid colorlan" onclick="openPage(\'../contract_bian/show.php?id='+d.id+'\');">流程(审批中)</span>'
                                    }else if(d.status == 1){
                                        return '<span class="list_billid colorlan" onclick="openPage(\'../contract_bian/show.php?id='+d.id+'\');">流程(审批通过)</span>'
                                    }else{
                                        return '';
                                    }
                                }else{
                                    return '<td>手动</td>';
                                }
                            }}
                        ,{field:'number',title:'变更单号',templet: function(d){
                                return '<span class="colorlan" onclick="show_contractbian('+d.id+')">'+d.number+'</span>';
                            }}
                        ,{field: 'bianfee', title: '本次变更金额(元)'}
                        ,{field: 'dt', title: '变更日期'}


                    ]]
                    , done: function (res) {
                        soulTable.render(this);
                    }
                });


                var mytableList22 = table.render({
                    elem: "#datalist_ming",data:res.data.list, toolbar: '#toolbarDemo_ming', page: false
                    ,limit:TabInitShow.limit,soulSort: TabInitShow.soulSort,method: TabInitShow.method, overflow: TabInitShow.overflow
                    ,defaultToolbar: TabInitShow.defaultToolbar,filter: TabInitShow.filter ,text: TabInitShow.text
                    ,request: TabInitShow.request,response: TabInitShow.response,contextmenu:get_table_contextmenu(soulTable)
                    , cols: [[
                        {type:'numbers',title:'序号'}
                        ,{field: 'name', title: '名称及规格'}
                        ,{field: 'unit', title: '单位'}
                        ,{field: 'num', title: '数量'}
                        ,{field: 'price', title: '单价(元)'}
                        ,{field: 'money', title: '金额(元)'}
                        ,{field: 'explain', title: '备注'}

                    ]]
                    , done: function (res) {
                        soulTable.render(this);
                    }
                });


                public_flow_show_display(res.data.billinfo);
                public_upload_show_file('upload_files', res.data.files);
                render_from();
            }
        });

        public_get_readsandlog('contract_cai', param_id);
    });

    function show_contractbian(id) {
        openPage('../contract_bian/show.php?id='+id);
    }



    function go_to_engin_xiang(){
        if(pub_enginid){
            openPage('../engin/xiang.php?id='+pub_enginid);

        }else{
            facade.error("暂无工程信息");return false;
        }
    }
</script>
</body>
</html>




